import django_filters
from myscheduler.models import *
from django_apscheduler.models import DjangoJobExecution


class SchedulerJobFilter(django_filters.FilterSet):
    JobName = django_filters.CharFilter(field_name='JobName',
                                           lookup_expr='icontains', label="任务名称")
    Jobtpye = django_filters.CharFilter(field_name='SchedulerTpye__Name',
                                            lookup_expr='icontains', label="任务类型")

    class Meta:
        model = SchedulerJob
        fields = {
        }


class SchedulerTypeFilter(django_filters.FilterSet):
    Name = django_filters.CharFilter(field_name='Name',
                                           lookup_expr='icontains', label="模板名称")

    class Meta:
        model = SchedulerTpye
        fields = {
        }


class SJobResultFilter(django_filters.FilterSet):
    job_id = django_filters.CharFilter(field_name='job_id',
                                           label="JobID")
    status = django_filters.CharFilter(field_name='status',
                                     lookup_expr='icontains', label="执行结果")
    runtime = django_filters.DateFromToRangeFilter(field_name='run_time', label='执行时间')

    class Meta:
        model = DjangoJobExecution
        fields = {
        }